package cn.xaut.XAUT迎春杯预热;

import java.util.Scanner;

/**
 * K - 区间和
 */
public class demoK {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int m = input.nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i++) 
            a[i] = input.nextInt();
        
        for (int i = 1; i <= m; i++) {
            int l = input.nextInt();
            int r = input.nextInt();
            int sum = 0;
            for (int j = l; j <= r; j++)
                sum += a[j];
            System.out.println(sum);
        }
    }
}
